package game

import (
	"wolfkill/module/role"
	"wolfkill/module/room"
	"wolfkill/module/user"
)

const (
	UserId     = "user_id"
	RoleId     = "role_id"
	RoomId     = "room_id"
	Status     = "status"
	DeadWay    = "dead_way"
	Select     = "select"
	GameId     = "game_id"
	UserNumber = "user_number"
	Exist      = "exist"
	AffectId   = "affect_id"
	Number     = "number"
	Affect     = "affect"

	Winner = "winner"
	Away = "away"
	WinnerLive = "winner_live"
	WinRound = "win_round"
	GameEventId = "game_event_id"
	EventTime = "event_time"
	Round = "round"
	CreateTime = "create_time"
	WhoBeforeId = "who_before_id"
	Skill = "skill"
	Doing = "doing"
	WhoAfterId = "who_after_id"
)

const (
	DayTime = "dayTime"
	NightTime = "nightTime"
)
const (
	Skill_Fear = "fear"
)

const (
	GetRole = "get_role"
	JoinGame     = "join_game"
	CloseRoom    = "close_room"
)
// 游戏表
type Game struct {
	GameId     string `json:"game_id" xorm:"pk notnull unique"`
	RoomId     string `json:"room_id" xorm:"notnull"`
	RoleId     string `json:"role_id" xorm:"notnull"`
	UserId     string `json:"user_id"`
	UserNumber int    `json:"user_number"`
	Status     bool   `json:"status"`
	DeadWay    string `json:"dead_way"`
	Select     bool   `json:"select"`
}
// 每个角色带着更新或者查询别人技能的func
//type GameRole struct {
//	GameId     string `json:"game_id" xorm:"pk notnull unique"`
//	RoleId     string `json:"role_id"`
//	UserId     string `json:"user_id"`
//	RoleSkill  string `json:"role_skill" xorm:"text"`
//}

// 游戏记录表
type GameRecord struct {
	// 游戏房间id
	RoomId string `json:"room_id" xorm:"pk unique notnull"`
	// 本局游戏胜方式
	Winner string `json:"winner"`
	// 胜利方式
	Away string `json:"away"`
	// 胜方生存人数
	WinnerLive string `json:"winner_live"`
	// 胜利的轮次
	WinRound int `json:"win_round"`
	// 创建时间
	CreateTime int64 `json:"create_time" xorm:"created"`
}

// 游戏事件表
type GameEvent struct {
	// 游戏事件id
	GameEventId string `json:"game_event_id" xorm:"pk unique notnull"`
	// 游戏房间id
	RoomId string `json:"room_id" xorm:"notnull"`
	// 主动方
	WhoBeforeId string `json:"who_before_id" xorm:"notnull"`
	// 使用技能
	Skill string `json:"skill" xorm:"notnull"`
	// 事件动作
	Doing string `json:"doing" xorm:"notnull"`
	// 被动方
	WhoAfterId string `json:"who_after_id" xorm:"notnull"`
	// 事件时间
	EventTime string `json:"event_time" xorm:"notnull"`
	// 编号
	Number int `json:"number" xorm:"notnull"`
	// 创建时间
	CreateTime int64 `json:"create_time" xorm:"created"`
}

// 游戏op
type GameOpIn struct {
	RoomId      string   `json:"room_id"`
	Number      int      `json:"number"`
	GameId      string   `json:"game_id"`
	RoleId      string   `json:"role_id"`
	RoleName    string   `json:"role_name"`
	WhoBeforeId string   `json:"who_before_id"`
	WhoAfterIds []string `json:"who_after_ids"`
}


type CreateGameIn struct {
	room.Room
	RoleIds []string `json:"role_ids"`
}

type CreateGameOut struct {
	RoomId   string `json:"room_id"`
	RoomCode string `json:"room_code"`
}

type JoinGameIn struct {
	UserId       string `json:"user_id"`
	RoomCode     string `json:"room_code"`
	RoomPassWord string `json:"room_pass_word"`
}

type JoinGameOut struct {
	role.Role
	Game
}

type ListPlayerOut struct {
	user.User
	role.Role
}

type GameStatus struct {
	RoomId         string `json:"room_id"`
	RoomGameStatus string `json:"room_game_status"`
}
